package com.wkhyapp.lm.app;

import android.app.Application;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import com.umeng.commonsdk.UMConfigure;
import com.wkhyapp.lm.constant.Constant;
import com.wkhyapp.lm.utils.FileUtils;
import com.wkhyapp.lm.utils.PreferenceUtils;

public class WkhyApp extends Application {

    public static WkhyApp application = null;

    @Override
    public void onCreate() {
        super.onCreate();
        application = this;
        UMConfigure.init(this, "6161305914e22b6a4f1933e8", "wkhy", UMConfigure.DEVICE_TYPE_PHONE, "");
        PreferenceUtils.initializeInstance(this);
//        PushManager.getInstance().initialize(this.getApplicationContext(), GeTuiPushService.class);
//        PushManager.getInstance().registerPushIntentService(this.getApplicationContext(), GeTuiIntentService.class);
        Constant.version = getVersionForCode();
        initFile();


    }
    public void initFile(){
        System.out.println("---"+ FileUtils.makeDirs(Constant.appFilePatch));
        System.out.println("---"+ FileUtils.makeDirs(Constant.imagFilePatch));

    }


    public static WkhyApp getAppContext() {
        return application;
    }

    /**
     * 获取版本号
     *
     * @return 当前应用的版本号
     */
    public String getVersionForCode() {
        try {
            PackageManager manager = this.getPackageManager();
            PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
            String version = info.versionName;
            return version;
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

}
